home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group98a.txt / 000001_icon-group-sender _Tue Jan 13 09:32:16 1998.msg < prev    next >
Internet Message Format  |  2000-09-20  |  3KB

  1. Return-Path: <icon-group-sender>
  2. Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
  3.     by baskerville.CS.Arizona.EDU (8.8.7/8.8.7) with SMTP id JAA26735
  4.     for <icon-group-addresses@baskerville.CS.Arizona.EDU>; Tue, 13 Jan 1998 09:32:15 -0700 (MST)
  5. Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
  6.     id AA20742; Tue, 13 Jan 1998 09:32:15 -0700
  7. X-Sender: nevin@pop.interaccess.com (Unverified)
  8. Message-Id: <v04003901b0e0c25d0101@[204.148.87.66]>
  9. In-Reply-To: <swampler-9800081533.AA0009292@orpheus.gemini.edu>
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset="us-ascii"
  12. Date: Tue, 13 Jan 1998 01:08:52 -0600
  13. To: icon-group@optima.CS.Arizona.EDU
  14. From: "Nevin :-] Liber" <nevin@pendragon-software.com>
  15. Subject: Re: Stripping blank and comment lines
  16. Cc: swampler@noao.edu (Steve Wampler)
  17. Errors-To: icon-group-errors@optima.CS.Arizona.EDU
  18. Status: RO
  19. Content-Length: 1609
  20.  
  21. At 9:33 AM -0600 1/8/98, Steve Wampler wrote:
  22. >   Write a program that strips out blank lines and comment lines (lines
  23. >   that only contain a comment) from Icon programs.  The program should
  24. >   accept 0 or more file names as arguments and copy the files to standard
  25. >   output with all blank and comment lines removed.  If no arguments are
  26. >   given, then the program should read from standard input.
  27.  
  28. I'll start the ball rolling.  Here is my solution; in the spirit of Steve's
  29. message to try and get some discussion going, I'll leave it up to others to
  30. comment upon the elegance/inelegance of it and to make suggestions on other
  31. ways to implement it.  Enjoy!
  32.  Nevin :-)
  33.  
  34.  
  35.  
  36. procedure main(LArguments)
  37.  
  38.     local    fInput
  39.     local    sLine
  40.  
  41.     every fInput := InputFiles(LArguments) do {
  42.         while sLine := read(fInput) do {
  43.             write(ValidSourceLine(sLine))
  44.         }
  45.     }
  46.  
  47. end
  48.  
  49.  
  50.  
  51. procedure InputFiles(LFilenames)
  52.  
  53.     local    sFilename
  54.     local    fFile
  55.  
  56.     if 0 = *LFilenames then {
  57.         return &input
  58.     }
  59.  
  60.     every sFilename := !LFilenames do {
  61.         if not (fFile := open(sFilename)) then {
  62.             write(&errout, "Cannot open ", image(sFilename), "
  63. for reading.")
  64.             next
  65.         }
  66.  
  67.         suspend fFile
  68.  
  69.         close(fFile)
  70.     }
  71.  
  72. end
  73.  
  74.  
  75.  
  76. procedure ValidSourceLine(sLine)
  77.  
  78.     sLine ? {
  79.         tab(many('\t '))
  80.         if ="#" | not move(1) then {
  81.             fail
  82.         }
  83.     }
  84.  
  85.     return sLine
  86.  
  87.  
  88. end
  89.  
  90. --
  91.  Nevin ":-)" Liber  <mailto:nevin@pendragon-software.com>  (847) 816-9926
  92.   Senior Software Engineer, Pendragon Software <http://www.webfayre.com/>
  93.  
  94.     Pendragon Software Corporation
  95.     1580 South Milwaukee Avenue, Suite 515
  96.     Libertyville, IL 60048-3776
  97.     voice:    (847) 816-9660
  98.     fax:    (847) 816-9710
  99.  
  100.  
  101.